package com.tapstitch.scm.common.utils;

import java.util.Arrays;
import java.util.List;

/**
 * @author zhenyu.guo
 * @date 2018/9/3.
 */
public enum TimeZoneEnum {
    // UTC + 8
    CHINESE("China", "中国时区", "Asia/Shanghai", Arrays.asList("CN", "HK")),
    // UTC - 7
    AMERICA_LOS_ANGELES("america", "美国洛杉矶时区", "America/Los_Angeles", Arrays.asList("US")),
    SPAIN("spain", "西班牙时区", "CET", Arrays.asList("ES")),
    PORTUGAL("portugal", "葡萄牙时区", "Portugal", Arrays.asList("PT")),
    // UTC + 4
    DUBAI("dubai", "迪拜时区", "Asia/Dubai", Arrays.asList("AE", "OM")),
    // UTC + 3
    ARABIC("arabic", "阿拉伯时区", "Asia/Riyadh", Arrays.asList("SA", "IR", "IQ", "KW", "BH", "QA")),
    // UTC + 2
    AMMAN("jordan", "约旦时区", "Asia/Amman", Arrays.asList("JO", "LB", "TR", "EG", "LY")),
    // UTC - 2  巴西
    BRAZIL("brazil", "巴西时区", "America/Sao_Paulo", Arrays.asList("BR")),
    // 墨西哥
    MEXICO("mexico", "墨西哥时区", "America/Mexico_City", Arrays.asList("MX")),
    PERU("peru", "秘鲁时区", "America/Lima", Arrays.asList("PE")),
    CHILE("chile", "智利时区", "America/Santiago", Arrays.asList("CL")),
    ARGENTINA("argentina", "阿根廷时区", "America/Argentina/Cordoba", Arrays.asList("AR")),
    PANAMA("panama", "巴拿马时区", "America/Panama", Arrays.asList("PA")),

    // UTC + 8
    UTC("UTC", "格林威治时间", "UTC", Arrays.asList("UK")),
    ;

    private String name;
    private String desc;
    private String value;
    /** 当前时区支持的国家 */
    private List<String> supportCountryList;

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    public String getValue() {
        return value;
    }

    public List<String> getSupportCountryList() {
        return supportCountryList;
    }

    TimeZoneEnum(String name, String desc, String value, List<String> supportCountryList) {
        this.name = name;
        this.desc = desc;
        this.value = value;
        this.supportCountryList = supportCountryList;
    }

    /**
     * Description: 根据国家简码获取时区
     *
     * @param countryCode 国家简码， 例如: 中国 CN , 美国:US  沙特:SA
     * @return com.ajmall.common.enums.TimeZoneEnum
     * @author wuqiong 2020-05-27 10:04
     */
    public static TimeZoneEnum getDefaultTimeZone(String countryCode) {
        if (countryCode == null || countryCode.length() == 0) {
            return AMERICA_LOS_ANGELES;
        }
        for (TimeZoneEnum timeZoneEnum : TimeZoneEnum.values()) {
            if (timeZoneEnum.getSupportCountryList().contains(countryCode)) {
                return timeZoneEnum;
            }
        }
        return ARABIC;
    }

}
